home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19981211-19990422 / 000430_news@watsun.cc.columbia.edu _Sun Apr 4 12:23:11 1999.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Return-Path: <news@watsun.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id MAA04554
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Sun, 4 Apr 1999 12:23:10 -0400 (EDT)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id MAA17138
  7.     for kermit.misc@watsun.cc.columbia.edu; Sun, 4 Apr 1999 12:18:00 -0400 (EDT)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: Is it possible to script a telnet session with bash?
  11. Date: 4 Apr 1999 16:17:54 GMT
  12. Organization: Columbia University
  13. Message-ID: <7e83bi$gnf$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@watsun.cc.columbia.edu
  15.  
  16. In article <37062a83.6682275@news.iea.com>,
  17. Michael Langley <mlangley@owt.com> wrote:
  18. : I am wondering if it is possible to script a telnet session with bash?
  19. :
  20. The best way to script a telnet session is with a telnet client that
  21. includes a built-in scripting capability, such as C-Kermit:
  22.  
  23.   http://www.columbia.edu/kermit/ckermit.html
  24.  
  25. This way you don't have to worry about interactions or misunderstandings
  26. between the shell, Perl, Expect, etc etc, and the Telnet client and
  27. server.  Here's a short example:
  28.  
  29.   define host xyzcorp.com
  30.   define user fred
  31.   undef password
  32.  
  33.   set network type tcp/ip
  34.   set host \m(host)
  35.   if fail stop 1 Can't open connection to \m(host)
  36.  
  37.   ; Prompt locally for password -- it's not good to put passwords
  38.   ; in scripts.
  39.  
  40.   while not defined password {
  41.     askq password { Password for \m(user) at \m(host): }  ; (doesn't echo)
  42.   }
  43.   input 20 login:
  44.   if fail stop 1 Timed out waiting for login: prompt
  45.   output \m(user)\13
  46.   input 10 Password:
  47.   if fail stop 1 Timed out waiting for Password: prompt
  48.   output \m(password)\13
  49.   connect
  50.  
  51. The \m(blah) notation indicates variable expansion, and \13 is the code
  52. for carriage return.
  53.  
  54. The "connect" command at the end puts you online with the remote host so
  55. you can interact with it directly.  Instead of "connect" you can, of
  56. course, also script any interactions with the host that you could do by
  57. hand, plus many that you could not, like transferring files.
  58.  
  59. C-Kermit also can make dialup and other types of connections, so the same
  60. scripting works for many connection types on many platforms.
  61.  
  62. Secure authentication methods (Kerberos, SRP) will be available in the
  63. forthcoming 7.0 version.
  64.  
  65. - Frank